<?
/**
*  客户重障统计
*  2013/8/20
*/
include("../webkit/include/simple_db.php");

include("session.php");
require("ajax_base.php");

$db = new SimpleDB();
$action = $_GET['action'];

if($action == "order_count") {
	$condition = "1=1";
	if(isset($_GET['time_range'])) {
		$arr = split("_", $_GET['time_range']);
		$condition .= " and (a.call_time between '".$arr[0]." 00:00:00' and '".$arr[1]." 23:59:59')";
	}
	$sql = "select b.client_no, b.client_name, b.mobilephone, count(a.id) as order_count, a.client_id from jx_order a Left Join jx_client b On a.client_id=b.id where $condition group by a.client_id order by order_count desc"; 
	echo to_grid_json($db, $sql, $dic_data, array("client_name"=>"blue_color_mapper","order_count"=>"red_color_mapper", "client_id"=>"client_id_mapper"));
}


function client_id_mapper($v, $row) {
	return "<a href=\"order_list.php?client_id=".$row['client_id']."\">查看客户工单</a>";
}
?>